<?php

class YExceptionTool extends Exception {/* {{{ */

    const NOVELID_ERROR         = 110121;
    const VCODE_ERROR           = 110122;
    const UPDATE_TYPE_ERROR     = 110123;
    const UPDATE_DATA_ERROR     = 110124;
    
    const PARAMPACK_ERROR       = 11000;
    
    /** 公共错误 */
    const UNKNOWN_ERROR         = 10000;
    const METHOD_MUST_GET       = 10001;
    const METHOD_MUST_POST      = 10002;
    const METHOD_MUST_SHELL     = 10003;
    const MYSQL_ERROR           = 10004;
    
    const USERNAME_ERROR        = 11005;
    const PASSWORD_ERROR        = 11006;
    const NAME_ERROR            = 11007;
    const MOBILE_ERROR          = 11009;
    const STATUS_ERROR          = 11010;
    const IDS_ERROR             = 11011;
    const UID_ERROR             = 11012;
    const SID_ERROR             = 11013;
    const NICKNAME_ERROR        = 11014;
    const AGE_ERROR             = 11015;
    const SCHOOLAGE_ERROR       = 11016;
    const ICON_ERROR            = 11017;
    const STUID_ERROR           = 11018;
    const COMPANY_ERROR         = 11019;

    const OPERNID_ERROR         = 11020;
    const TIMES_ERROR           = 11021;
    const NUMBER_ERROR          = 11022;
    const ASK_ERROR             = 11023;
    const ID_ERROR              = 11024;
    const CATEGORY_ERROR        = 11025;
    const OID_ERROR             = 11026;
    const HOMEWORKID_ERROR      = 11027;
    const TYPE_ERROR            = 11028;
    const SECTIONID_ERROR       = 11029;
    const DATE_ERROR            = 11030;
    const MID_ERROR             = 11031;
    const STIME_ERROR           = 11032;
    const ETIME_ERROR           = 11033;
    const SCORE_ERROR           = 11034;
    const STAR_ERROR            = 11035;

    const USER_NOFOND_ERROR     = 12001;
    const USER_STATUS_ERROR     = 12002;
    const USER_NOT_LOGIN        = 12003;
    const IDENTITY_ACCESS_ERROR = 12004;
    const MOBILE_USED_ERROR     = 12005;
    const STUDENT_NOTIN_TEACHER = 12006;
    const HOMEWORK_NOT_EXITS    = 12007;
    const USER_TYPE_ERROR       = 12008;
    const REPASSWORD_ERROR      = 12009;

    private static $_exceptions = array (
        
        self::NOVELID_ERROR         => '小说ID错误',
        self::VCODE_ERROR           => '验证码错误',
        self::UPDATE_TYPE_ERROR     => '参数错误',
        self::UPDATE_DATA_ERROR     => '数值错误',
        
        /** 公共错误 */
        self::UNKNOWN_ERROR         => '错误，请重试!' ,
        self::METHOD_MUST_GET       => '请求方法必须为get' ,
        self::METHOD_MUST_POST      => '请求方法必须为post' ,
        self::METHOD_MUST_SHELL     => '请求方式必须为shell' ,
        /** 参数错误提示 */
        self::PARAMPACK_ERROR       => '参数错误' ,
        self::USERNAME_ERROR        => '用户名不合法' ,
        self::PASSWORD_ERROR        => '密码不合法' ,
        self::REPASSWORD_ERROR      => '确认密码不合法' ,
        self::NAME_ERROR            => '名字不合法' ,
        self::MOBILE_ERROR          => '手机号不合法' ,
        self::STATUS_ERROR          => '状态错误' ,
        self::IDS_ERROR             => 'id错误' ,
        self::STUID_ERROR           => '学生id不合法' ,
        self::OPERNID_ERROR         => '琴谱id不合法' ,
        self::TIMES_ERROR           => '练习时间不合法' ,
        self::NUMBER_ERROR          => '次数不合法' ,
        self::ASK_ERROR             => '要求不合法' ,
        self::ID_ERROR              => 'ID不合法' ,
        self::CATEGORY_ERROR        => '分类id错误' ,
        self::OID_ERROR             => '曲谱id错误',
        self::HOMEWORKID_ERROR      => '作业id错误',
        self::TYPE_ERROR            => 'type参数错误',
        self::SECTIONID_ERROR       => 'sectionid参数错误',
        self::DATE_ERROR            => 'date参数错误',
        self::MID_ERROR             => '歌曲id参数错误',
        self::STIME_ERROR           => '开始时间参数stime错误',
        self::ETIME_ERROR           => '开始时间参数etime错误',
        self::SCORE_ERROR           => '分数参数score错误',
        self::STAR_ERROR            => '分数参数star错误',


        /*         * 逻辑错误* */
        self::USER_NOFOND_ERROR     => '用户名或者密码不正确' ,
        self::USER_STATUS_ERROR     => '用户状态异常' ,
        self::UID_ERROR             => 'UID错误' ,
        self::SID_ERROR             => 'SID错误' ,
        self::NICKNAME_ERROR        => '昵称错误' ,
        self::AGE_ERROR             => '年龄错误' ,
        self::SCHOOLAGE_ERROR       => '练琴时间错误' ,
        self::ICON_ERROR            => '头像错误' ,
        self::USER_NOT_LOGIN        => '没有登陆' ,
        self::IDENTITY_ACCESS_ERROR => '该用户身份无权操作' ,
        self::MOBILE_USED_ERROR     => '手机号被使用' ,
        self::STUDENT_NOTIN_TEACHER => '该学生不在该老师名下' ,
        self::COMPANY_ERROR         => '机构错误' ,
        self::HOMEWORK_NOT_EXITS    => '作业不存在',
        self::USER_TYPE_ERROR       => '该用户身份无法登陆该app',
    );

    public function __construct ($code , $msg = 'unknown')
    {/* {{{ */
        $msg = isset ( self::$_exceptions[ $code ] ) ? self::$_exceptions[ $code ] : $msg;
        parent::__construct ( $msg , $code );
    }

    /* }}} */

    public static function getMsg ($code = 10000)
    {
        return isset ( self::$_exceptions[ $code ] ) ? self::$_exceptions[ $code ] : '错误, 请重试!';
    }

}

/*}}}*/
       